08 - Electronics Design

Designing a PCB for My Final Project

This was one of the weeks, I was looking for the most as I wanted to learn how to properly to electronics design really a lot. Turns out, it is actually (relatively) easy. It includes a lot of researching about electronics components, which may fulfil the function you want it to do, reading - among others - about their pinout and getting to know how they work. The last part is actually optional but for me it does not work without it (and also I like to know what I am doing).

This weeks's assignment were:

  • Group Assignment
    • Use the test equipment in your lab to observe the operation of a microcontroller circuit board
    • Send a PCB out to a board house
  • Individual Assignment
    • Use an EDA tool to design a development board to interact and communicate with an embedded microcontroller
    • Produce it
    • Test it
    • For extra credit
      • Try another design workflow
      • Design a case for it
      • Simulate its operation

Group Assignment

The group assignments are hosted on a different website. You can find the one for this week here.

This week we had to investigate the operation of a microcontroller, which can mean many things. Therefore, we investigated the power consumption, the behavior of the pin during the blink example from Arduino and a pulse width modulation (PWM) output signal.

Measuring the power consumption of a microcontroller can be easily done with a bench power supply. If the voltage is regulated and the current is set to load-dependent, then the power consumption equals the product of these two as power equals voltage times current.

In addition, a multimeter can be used, or actually two. To measure the voltage, the multimeter must be placed in parallel to the microcontroller, i.e. connected to the same VCC and ground. For the current, the multimeter however must be placed in series. If two multimeter are used like this simultaneously, the power can be calculated from both of these readings.

For the other operations, we investigated, namely the blink example and the PWM output, we did not use a bench power supply or multimeters to measure the voltage. Here, the reason is that they do not allow for a high time resolution but are rather slow. Therefore, another electrical instrument was used, the oscilloscope.

An oscilloscope is a more advanced measuring (and sometimes power generating) machine that is typically used to analyze waveforms of signals. The oscilloscope we used for the group assignment had two inlets for measuring with two cables each. With it, we captured the signals of the blink example but also from the PWM signal.

After capturing the signal and stopping the measurement, we zoomed in (only time-wise) on a single HIGH-phase. Then, we were able to measure different parameters of the waveform, e.g. amplitude, frequency, duty cycle and so on. Here, the microcontroller operation was as we expected with the script we uploaded to it. However, it was very interesting to see that we can also time-wise resolve the PWM signal.

Multimeter

Oscilloscope

Individual Assignment

As always, it is nice to actually produce something for the assignment, that is useful. Optimally, it should even be useful for my final project. Therefore, I tried to design a PCB, that can fulfil the functions I need to implement for my final project.

Before starting with the actual detailed design, I researched about what components exist that implement the desired functions, which one to pick with regards to availability and price and how they work. Next, I started designing the PCB with its logic and the layout, fabricated it using milling and lastly tested it.

Selection of Components

There are many functions, I would like to implement for my final design. However, as this week's topic only considers electrical elements, I focussed only on the functions I need to be able to implement and the selection of components to do so, namely:

  • Rotate a shaft with a NEMA 17 stepper motor.
  • Sense the angle of the rotating shaft.
  • Switch an LED strip on and off and dim it.
  • Optionally, let a camera record an video or take an image.

The last aspect, I defined as optionally because controlling a camera module on a PCB requires an advanced microcontroller or even - one level up - a small computer like a RaspberryPi. However, these are relatively expensive and therefore I defined it as optionally. Instead of it, I could also use a complete camera system and control it manually in addition to the functions above.

Lastly, I would like to control these functions on my computer with a graphical user interface. My computer could communicate to the microcontroller on the PCB which will distribute the commands to the according peripherals. For this, I will need to establish a communication connection - preferably with USB.

The Motor and Its Driver

In the previous assignment, i.e. computer-controlled machining, I already made the frame, to which a motor can be attached. Here, I picked the NEMA 17 stepper motor as the motor to rotate the shaft. I had not really explained why I selected it but there are several reasons.

First of all, all components mounted on the rotating shaft should be balanced, even the camera and its mount, such that the motor which rotates the shaft does not require to be strong. This also allowed me to go for one of the cheapest motors available as the costs are also always a factor to take into consideration.

NEMA 17 Stepper Motor

Lastly, availability was potentially the most important aspect. In the lab, we already had a NEMA 17 stepper motor available, more specifically this one. Therefore, instead or buying a new one, I could simply take this one. According to the datasheet, this motor needs a current of 1.5 A per phase.

In order to control a stepper motor, a motor driver is needed. Fortunately, we also had a motor driver available that is compatible with the NEMA 17 stepper motor, namely this one. It is a breakout board that carries an A4899 motor driver. It comes with male 16 pin headers soldered to it and a heat sink which dissipates head and therefore reduces the risk of overheating.

A4899 Motor Driver Carrier

The vendor also supplies a minimal wiring diagram for the motor driver. It shows that the motor driver needs to have at least four connections to the microcontroller, i.e. power (3 - 5.5 V), ground (GND), a step pin and a direction pin. Additionally, the motor driver can be powered with an external power supply with 8 - 35 V and 1 A or, in case the heat sink is used, up to 2 A per phase. With the pins 2B, 2A, 1A and 1B the motor is connected to the motor driver. The schematics of the diagram are shown below.

Minimal Wiring Diagram of Motor Driver

Angle Sensor

An angle can be sensed with a variety of sensors. However, while I was temporarily working for maraneo GmbH, a company that designs, develops and fabricates underwater scooters, I saw them using magnets inside of a wheel to control the speed of the scooters, similar to a thumbwheel for joysticks. This kind of setup allows to have a watertight electric circuit with a sensor while the moving part does not need to be watertight.

I was really excited about these sensors when I saw them the first time as it appeared so easy to me. Since them, I wanted to use them in any kind of project. Finally, I could use one of these sensors, namely to sense the angle of the rotating shaft. Hence, I researched about it and found out these sensors are called Hall sensors as they use the Hall effect to sense a magnetic field.

The Hall effect is the production of a potential difference, i.e. a voltage, across an electrical conductor perpendicular to the direction of the electric current in the presence of a magnetic field. A Hall sensor makes use of this effect to sense the strength and/or orientation of a magnetic field traversing them.

Apparently, a Hall sensor is a relatively common sensor as such a sensor was also available in the lab, namely this one. It consists of a breakout board with the sensor A3141 and an amplifier LM393. It also has a potentiometer to control the sensitivity of the sensor. Turning it clockwise increases the sensitivity. In total, there are four pinouts, one for power (3.3 - 5V), ground, an analog and a digital output.

Breakout Board with Hall Sensor (Black Box in the Top)

A digital output would only supply the knowledge of whether a magnet is present or not. However, as I also would like to measure the orientation of a magnet placed on the rotating shaft I will to connect the microcontroller to the analog output of the module, in addition to the power and ground pins.

LED Strip and MOSFET

As a last task, I had to select the right components for controlling the LED strip to switch it on and off and to dim it. This was potentially the most difficult task for me as I had to understand the control-unit. I had no clue how to do it but my local instructor was really helpful here and told me to use a so-called MOSFET which stands for metal–oxide–semiconductor field-effect transistor.

As the name says, a MOSFET is a special kind of transistor. Therefore, I started to read about transistors and MOSFETs. I found this webpage really helpful. A MOSFET usually has three pinouts, a gate (G), a drain (D) and a source (S). The gate can be controlled with a voltage. In case it is above a threshold voltage, the gate opens and allows current to flow from the drain to the source. In case it is below the threshold, the gate is closed and no current can flow.

There are only two more aspects, which have to be considered, namely a gate and pull-down resistor. A MOSFET or actually the gate-source connection acts apparently like a capacitor. Right after turning the MOSFET on, the capacitor is not yet fully charged and therefore, current can flow through it. However, a microcontroller only can take a limited amount of current and therefore it is important to use a gate resistor to limit the current.

Additionally, after closing the gate, the charge across the gate-source connection must be discharged. To do this, a pull-down resistor must be used. More information can be found here.

Exemplary Circuit with a MOSFET (on the Right)

Again, I was happy to find out, we had a MOSFET available in the lab, namely this one of the type TO-252AA. It can handle a voltage of up to 100 V and a current of up to 4.3 A.

As an LED strip, I bought this one as it is very bright with a cold-white light temperature for a good contrast. It operates with a voltage of 24 V with a power consumption of 10.8 W per meter. As I will use approximately 100 cm of it, its power consumption should amount to about 10.8 W. With the equation I = P/V, i.e. current equals the power divided by the voltage, this results in a current 0.45 A.

MOSFET Type TO-252AA with Gate (Left), Drain (Top) and Source (Right)

Power Supply

Not only the LED strip but also the motor or actually the motor driver needs an external power supply. To limit the resources, these power supplies can be incorporated in a single. However, the motor and the LED strip will need to be placed in parallel to each other to not affect the motor by the MOSFET.

In addition, the voltage and current that the power supply generates must spe specified. The LED strip requires 24 V which also falls into the range of 8 - 35 V that the motor can take. Additionally, the LED strip needs approximately 0.45 A and the motor 1.5 A up to 2 A. An external power supply should therefore supply a voltage of 24 V and a current between 1.95 A and 2.45 A. This equals a power between 46.5 W and 58.8 W.

CAD of PCB

After having picked the components, I was now able to start with the CAD of the PCB. In a previous assignment, i.e. electronics production, our local instructor already taught us how to use the software KiCAD for electronics design as an electronic design automation (EDA) tool. The first step to was to integrate the FabAcademy libraries for symbols and footprints. You can find a detailed description of how to do this here.

After created a new project, I started with designing the logics in the schematics file and consecutively the physical layout of the board.

Schematic Design

For designing the schematics, I opened the .kicad_sch file of the project, which was initially empty. It is good practice to start the design with adjusting the page settings, i.e. inputting a title, a date and some other information in table in the bottom right of the page.

Window of the File for the Schematics in KiCAD

Then, I added the first symbol to the page by going to the symbol library with pressing the key "A" and selecting it. Here, the first symbol is usually the microcontroller. In this case, I chose to use an ATtiny1614, which is apparently one of the best microcontroller available for a good price as recommended by my local instructor. To add the microcontroller's symbol to the schematics, I searched for "1614" in the library and selected the "Microcontroller_ATtiny1614-SSFR" entry of the "fab" library, i.e. the library of the FabAcademy. It has 14 pins including VCC (5V) and ground, 12 of which can be used as GPIOs. Furthermore, multiplexing is applied to the GPIOs and hence these include I2C and UART communication and a pin for programming the microcontroller, the Unified Program and Debug Interface (UPDI).

Symbol of ATtiny1614 Microcontroller

After adding the microcontroller's symbol, I immediately attached a VCC and GND symbol to the microcontroller to power it. Then, I added pin headers for the communication protocols. These include a 1x4 pin header with GND, SDA, SCL and VCC for I2C communication and a 1x6 pin header with GND, CTS, VCC, Tx, Rx, RTS for UART communication. For this order of pins for the FDI connection, I used the documentation from Jeff, a FabAcademy student in 2021.

Microcontroller with Communication Pin Headers

In my design, it is important to note, that Rx and Tx stand for the Rx and Tx pin of the external device such that the micrcontroller receives data at the RxD pin and transmits from the TxD pin. Here, I used global labels for clarity which can be added with Ctrl + L.

For the I2C communication, the data pins also have to be puled-up with VCC with a 4.7 kiloohms resistor. I personally did not know that, but my local instructor told me and my fab mates to do so. Lastly, I also added a 1x3 pin header to the UPDI pin with VCC and ground.

Next, I added two 1x4 pin headers with power (VCC) and ground (GND) to be able to connect to these. Additionally, in case the power supply to the microcontroller comes from a source that is not extremely stable and steady, a filter has to be applied to the power input for consistency. This can be done with capacitors. Here, I used two different ones to filter out noise with different frequencies. Their symbols are from the "C_1206" entry of the "fab" library.

Power Pin Headers and Capacitors

Then, I added the motor driver to the schematics. The library did not have the motor driver of the exact same brand and manufacturer, but I found the "Pololu_Breakout_A4988" entry in the "Driver_Motor" library of KiCAD. However, I checked the datasheet by right-clicking on the symbol of the motor driver and selecting "Show Datasheet" and whether its footprint matches the footprint of the motor driver I am using as shown in its datasheet here.

As the footprints matched, I continued with adding VCC, VMOT (24 V) and GND to it. Additionally, as shown in the minimal wiring diagram above, VMOT and GND need to be connected with a 100 uF capacitor which I therefore added as well. For this, I cannot use the 1206 size components as they cannot handle a voltage of up to 24 V.

Therefore, I searched for another one and found this one. Initially, I used a capacitor of the "fab" library which matched the capacitor the closest, namely the "CP_Elec_D6.3mm_H6.1mm" entry, and later, I changed the actual footprint of it (see below).

Next, I connected the pins 1B, 1A, 2A and 2B to a 1x4 pin header which will be the wiring to the motor. The pins MS1, MS2 and MS3 were not connected in the minimal wiring diagram and I therefore added a no-connection flag to them as indicated with the "X" symbol. Then, I placed a wire from the SLEEP pin to the RESET pin as shown in the minimal wiring diagram ass well. Lastly, I connected the the STEP, DIR and ENABLE pin to the microcontroller by using global labels. The latter was used to be able to switch the motor on and off.

Schematics for Motor Driver

The schematics for the Hall sensor were relatively easy. As the Hall sensor would be placed somewhere else than the PCB, I only added a 1x3 pin header to connect to it via jumper cables. Here, the pins must be connected to VCC, GND and the analog reading of the sensor.

Schematics for Hall Sensor Pins

For designing the LED strip and its control, I started with the placing the MOSFET. For this, I used the "Transistor_MOSFET_NCh_TO252" symbol of the "fab" library. I again checked whether it is the right footprint by using the datasheets. As this was the case, I continued with the design by connecting the source to ground, and the drain to the power supply of 24 V with the LED strip placed between them. To be able to connect the external power supply and the LED strip to the PCB, I added 1x2 pin headers to the schematics at their according place.

Schematics for LED Strip, Its Power Supply and the MOSFET

Lastly, I added a microcontroller's pin to the gate of the MOSFET via a global label and placed a gate resistor and the pull-down resistor between them. I set the resistance of the gate resistor to 1000 ohms to limit the current to I = R/V = 5 V/1000 ohms = 5mA which is well below the maximum of the microcontroller, namely 40 mA. For the pull-down resistor, I used a typical value of 10 kiloohms.

As the last components of the PCB, I added some additional peripherals that are built-in on the board. This would allow me to test the functionality of the board without attaching any external components.

The first component I designed is a power LED, i.e. an LED with placed between VCC and GND including a resistor in series with a resistance of 200 ohms to limit the current through the LED to I = V/R = 5 V/200 ohms = 25 mA. This current is the maximum DC forward current for an LED as described in its datasheet.

Then, I added a second LED that could be switched on if the microcontroller outputs a high voltage and a button which the microcontroller could be able to read as an input. These are the same designs as I had already done for the electronics production week.

Schematics for Other Peripherals

Lastly, I added all the global labels for inputs and outputs of e.g. the motor driver, the MOSFET, the hall sensor and other peripherals to the microcontroller. This is how the complete schematics look like.

Complete Schematics

With the schematics being done, I saved the file and proceeded with the board layout by pressing a green button in the top row of buttons saying "Open PCB in Board Editor".

Opening the PCB

Designing the Board Layout

Once the schematics were done, I proceeded with the physical layout of the PCB. Initially, when opening the board editor to edit the .kicad_pcb file, the page is empty.

Initial Page in Board Editor

Hence, I first had to update the file by pressing a button on the right of the top row of buttons saying "Update PCB with changes made to schematics".

Updating the PCB

After updating the PCB, several components appeared that I had to place somewhere on the page with clicking to the according position. Here, I placed them in the top left corner.

Next, I changed the footprint of the capacitor. This has to be done as I only had used a part from the library which closely but not completely resembled the actual part. I did this by selecting the according footprint and then right-clicking on it and clicking on "Open in Footprint Editor". This opened another dialog where I was able to edit the footprint.

Packaging of the Capacitor in Datasheet

Editing the Footprint

Editing the Pads of the Footprint

In the editor, I double clicked on the first pad to change its properties. In the new dialog, I changed the pad size X to 3.5 mm, Y to 1.6 mm and the position X to -2.8 mm. After pressing "OK", I repeated these steps for the second pad, however, the position X was now 2.8 mm to guarantee a spacing of 2.1 mm between the pads. Lastly, I saved this new footprint to the "fab" library with a new name and closed the editor.

Footprint of the Capacitor

Next, I also changed the footprints for all pin headers. As the pads are circular with quite a small width, the pins that are soldered to it are not really strong. Therefore, I changed the footprint in the editor as well. Here, I firstly edited one pin, where I set the shape to an oval with a pad size X of 3 mm and Y of 1.7 mm. Additionally, I set the hole diameter to 1 mm. Within the footprint editor, I then right-clicked on a pad and selected "Push Properties to Other Pads". This opens a dialog where I unselected all options to push the properties to all pads of this footprint. Then, I saved this footprint in the "fab" library and repeated these steps for all other pads.

Pad Properties

Push Pad Properties To Others

Select Pads to Push Properties To

This is how the changed footprints look in comparison to the previous version.

All Components Initially Placed on Page

All Components After Changing the Footprints

Then, I started moving the components. A good start is to drag the center piece of the PCB, namely the microcontroller, to the middle of the page. The remaining steps are difficult to explain as it involves a lot of intuition and trial and error as well as logic. It is a good start to neglect the ground and power pins and concentrate on the pads that are directly connected to one of the GPIOs of the microcontroller. The small thin lines, called ratsnests, can help to show the user where connections have to be made. This is what I came up with:

Initial Layout of the Components

At this point, I was not sure, whether the layout works out in the end. By this, I mean that all required connections can be made without needing to go to a second layer of copper.

However, before wiring can be done, the width and clearance of the tracks in the default net class must be adjusted. For this, I went to File > Board Setup which opened another dialog, where I changed the clearance and track width to 0.5 mm.

Going to the Board Setup

Changing the Net Classes

Then, I started wiring the components while also moving them tighter together. For me, personally, designing the board layout is not only similar to solving a riddle but it is also a lot about aesthetics. I guess this is why I like it so much.

After a while, I had all components wired up. I also added a filled zone connecting to ground. In this section of the electronics production week, I describe this step in more detail. The image below shows, how the results look like.

Layout with Wired Components

However, the tracks with 24 V leading from the power supply to the motor driver and the LED strip will need thicker tracks due to the relatively high current. KiCAD has an built-in tool to calculate the track widths which can be reached via the initial window where the files can be seen as well. On the right side, different viewers and editors are available. Here, the seventh from the top named "Calculator Tools" can be used for calculating the track widths. Clicking on it opens another window, where the user can choose different parameters to calculate on the left. After going to "Track Width", I input a current of 3.5 A, a temperature rise of the default 10°C and a conductor length of 50 mm. On the right, this displays the track width of roughly 1.6909 mm for a trace thickness or copper layer thickness of 0.035 mm.

Calculating the Track Width for 24 V and 3.5 A

After this, I went to File > Board Layout in the PCB editor to open the net classes again. Here, I added another class which I called "PWR_24V" with a track width of 1.7 mm and a clearance of 1 mm. Below the list of netclasses, I assigned the patterns "+24V" and "drainMosfet" to the class "PWR_24V".

New Net Class for 24 V Tracks

To implement the change I did to the track widths and clearances, I selected all tracks and pressed "E" to edit their properties. This opened another dialog, where I ticked the box for "Use net class widths". After pressing "OK" the changes of the net classes were implemented into my design. This is how it looked:

Layout with Wired Components and Thicker Tracks for 24 V Tracks

Lastly, I added a polygon as an outside edge and two circles with a radius of 1.796 mm in opposite corners of the polygon for mounting the PCB to something. I selected these three shapes, pressed the key "E" to edit their properties. Here, I selected the "Edge.Cuts" as a layer, unticked the box for "Filled shape" and confirmed the changes. I pressed the key "B" one last time to update the filled shape. With this, I finished the PCB layout. This is how it looks:

Completed PCB Layout

PCB Fabrication File

After designing the board layout, the fabrication file has to be generated. For some machines, the export is just an image, e.g. with a .png or .svg file format. However, the mill we are using, the LPKF ProtoMat 1S04, needs Gerber files. These can be exported by clicking on File > Fabrication Outputs > Gerbers (.gbr)...

This opens another dialog which allows the user to specify some exporting settings. The settings I used are in more detail described in this section of the assignment for electronics production.

Exporting Fabrication Outputs

Exporting the design as Gerber files with the customized settings resulted in four files, an drill file with a .drl ending, an Edge-Cuts.gbr and F-Cu.gbr file for the edge cuts and the copper layer, respectively, and lastly a Gerber Job file with a .gbrjob ending.

CAM Processing

For milling the PCB, the lab has a LPKF ProtoMat S104 PCB mill. It comes with a software, that includes a CAM processor and controls the board production, which is called LPKF CircuitPro. This software was opened on the computer connected to the mill.

The settings for the CAM processing are in more detail described in this section. For the production of this PCB, the very same settings were used.

PCB Fabrication: Milling

After the CAM processing was completed in the software CurcuitPro, the fabrication can be conducted with controlling the machine with the very same software. This only includes to start a Wizard that instructs the user with the details of the steps, e.g. mounting the material, placing the design on the milling bed. The details of these steps are described in this section of the electronics production week.

Milled PCB

Before milling the top, the machine makes a test cut that is captured by a camera. By this, the width of the cut is measured such that the machine automatically adjust the height and by the the width of the trace. However, after the first test cut, the machine had difficulties to focus it properly. Presumably because the milling head was placed next to the material to place the camera on top of it. Therefore, I conducted a second test, which in some way ended up in the middle of the motor driver. However, it did not cut through anything and by this isolate anything. Nevertheless, the mill still was not able to focus the cut properly. It was not only after the third cut that I had figured out why it did not focus properly for the second cut. As it already was the late afternoon with a beautiful spring day, one of the first ones this year, the sun was shining through the window onto the copper. After shading the mill, focussing went on without any problems.

Soldering on the PCB

After the milling was complete, I continued with soldering the components to the board. For this, I firstly cleaned the PCB with Acetone and then soldered the components onto it with the method an tools described in this section. In total, the following components are needed:

  • Microcontroller ATtiny 1614
  • Motor Driver A4988
  • 2x 1x8 Pin Headers Female for Mounting the Motor Driver
  • 2x 1x2 Pin Headers
  • 2x 1x3 Pin Headers
  • 3x 1x4 Pin Headers
  • 1x6 Pin Headers
  • Button
  • 2x LEDs Size 1206
  • 0.1 uF Capacitor Size 1206
  • 1 uF Capacitor Size 1206
  • 100 uF
  • 2x 220 Ohms Resistors Size 1206
  • 1x 1000 Ohms Resistors Size 1206
  • 2x 4.7 Kiloohms Resistors Size 1206
  • 2x 10 Kiloohms Resistors Size 1206
  • MOSFET NCh TO-252AA

Components for Soldering

As the microcontroller was not available in the beginning, I started soldering the SMT components around it. This included the LEDs, the resistors, the capacitors, the button and the MOSFET. There was only one exception, namely the 100 uF capacitor for the motor's power supply as I had ordered it but it has not arrived yet. This is how the PCB looked like after soldering these components to it:

Soldered SMTs

I had difficulties with the ground connection of the pull-down resistor of the button which is in the image immediately on the left of the button. As you can see, the solder spread over the copper layer as I tried to melt it. However, after a while the solder was really difficult to melt. Then, my instructor helped me out by removing some solder and applying some flux. Over the next few solder points, I also used some flux and that also helped a lot.

Then, I gained access to the ATtiny 1614 and was able to solder it as well. I did not know actually which side was which. However, my local instructor showed me that the microcontroller had a small point in one corner. This is where the counting of the pins start. With this information, I was able to position and solder it to my PCB. This point is however so small, that is is very difficult to see without the microscope. Therefore, I think it does not even show in the images. Have a look yourself. It should be in the top left corner.

Soldered Microcontroller

The capacitor for the motor driver still had not arrived. Therefore, I continued with soldering the UPDI pins to be able to program the microcontroller. Here, I tried a new method. The board I previously made in the electronics production week only had relatively small male pins sticking out from it. Additionally, soldering them was pretty difficult as the plastic parts keeping them in a distance and in parallel were in the way of the soldering ion. Therefore, I now tried to place the plastic under the PCB and let the pins go through them and the hole such that their maximum length is reached while being stable. The image shows how I placed them exactly.

Soldered Pins

Testing the Preliminary PCB

After having soldered the microcontrollers, the SMT components and the UPDI pins to the board, it was ready for being tested. Even though it is not complete, it could already interact with an LED and a button. Therefore, instead of waiting for the remaining components to arrive, I already continued with testing the board which is firstly done with testing the soldered connections with a multimeter and then the microcontroller by programming a basic code.

Testing With a Multimeter

Testing the PCB with a multimeter is done in the continuity mode. In case there is an electrical connection between two places, which are touched by the tips of the cables, the multimeter beeps. Hence, it can be used to detect whether a wanted connected was properly made or any unwanted connections was made accidentally. A more detailed list of what should be tested is shown in this section of the electronics production week.

After having conducted these tests, I was able to state that no connection is faulty! Soldering was therefore a success. I had neither connected traces that should not have been connected nor did I not make a connection where it was wanted. Therefore, I was able to continue with the next phase of testing, namely the testing with programmed code.

Multimeter with Continuity Mode (Third on the Left)

Testing With Programmed Code

For the second phase of testing, i.e. with programming the board, I firstly had to connect my board to a programmer board. In contrast to the PCB I made in the electronics production week, this micrcontroller does not have a bootloader already burned onto it. Therefore, a programmer board is used. For this, my local instructor gave me a board he designed and made. The documentation for this can be found here. It carries a FT230x chip and offers a UPDI and FTDI connection. The former consist of three pins, VCC, ground and the UPDI pin, the same as for the board I designed.

To connect my board to the programmer board, I simply used three female to male jumper cables, a red one for VCC, black for ground and a purple one for the UPDI pin. I furthermore used an USB cable to connect the programmer board to my computer. Directly after plugging the programmer board into my computer, the power LED on my board switched on - as it was designed to do.

Power LED Turns On When Connected to a Powered Programmer Board

Next, I had to setup the IDE to program my board through the programmer. Here, I used the Arduino IDE and roughly followed this tutorial. Additionally, a dear friend on mine helped me out a lot with these steps. So, thank you Leen!

The first step of setting up the Arduino IDE was to install the ATtiny1614 board which is in the "megaTinyCore" package for the board manager. To install it, I went to File > Preferences and added the URL http://drazzy.com/package_drazzy.com_index.json to the list of additional board manager URLs.

After closing the preferences dialog, I went to Tools > Board > Board Manager... and searched for the megaTinyCore and installed it.

Installing the "megaTinyCore" Board Package

After the package had installed, I selected the ATtiny as the current board in the dropdown "Tools".

Selecting the ATtiny 1614 Board

I furthermore selected "ATtiny1614" as the chip and "SerialUPDI - 230400 baud" as the programmer. With these steps I was done with setting up the Arduino IDE.

Lastly, it was time to program something. For this, I used the example sketch for blinking an LED that can be found in File > Examples > 01.Basics > Blink. In this code, I only defined the output pin with the variable led_pin and then replaced the variable LED_BUILTIN with it.

However, I was not sure how to define the pin, i.e. what its value should be. For this, I checked how the pins of the ATtiny 1614 are referenced in the Arduino IDE simply by googling "ATtiny1614 Arduino pinout". This resulted in the image shown below.

Arduino Pinout of the ATtiny 1614

I matched the pinout of the schematics with the layout on my board and concluded that the built-in LED is connected to pin number 12. As shown in the pinout of the datasheet, this pin is the "PA2" pin. I lastly entered PA2 into the sketch as the value of the led_pin variable. This is how the complete code looks like:

// Define the pins of the built-in LED on the PCBy
const int led_pin = PA2;

// the setup function runs once when you press reset or power the board
void setup() {
	// initialize digital pin led_pin as an output.
	pinMode(led_pin, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
	digitalWrite(led_pin, HIGH);   // turn the LED on (HIGH is the voltage level)
	delay(1000);                   // wait for a second
	digitalWrite(led_pin, LOW);    // turn the LED off by making the voltage LOW
	delay(1000);                   // wait for a second
}

After trying to upload this code to the board by pressing the upload button in the Arduino IDE, this sketch actually gave me an error message saying "'PA2' was not declared in this scope". Apparently, for the Arduino IDE, the blue and orange labels for the pins are needed. Therefore, I simply changed PA2 to 9, i.e. I changed the second line to

const int led_pin = 9;

and this worked! After the upload was successfully completed, the built-in LED was switched on for a second and then switch off for another repetitively.

Blinking LED of the designed PCB

Soldering the Remaining Components

Even though I tested the board and programmed it already, not all components were soldered to the board as they still were not delivered. However, after about a week, the delivery had arrived and I was able to finish soldering.

The first component, I added were the connections to the LED strip and the power supply. However, I actually changed my mind here and, instead of using two 1x2 pin headers, I decided to go for mount screw terminals for a better and more permanent connection.

Even though, I selected a small size, the pins of them were slightly to far apart and to big for the holes drilled during PCB manufacturing. Therefore, I had to widen the holes and bend the pins of the screw terminals slightly, as you can see in the photo.

Screw Terminals Instead of Pin Headers for the LED Strip and the Power Supply

For widen the holes, I used a rotary tool commonly know as a dremel, which however only is a brand of rotary tools. In this case, I used one from the company Proxxon equipped with a small drill bit, i.e. a diameter of 1.2 mm, and placed vertically in a stand. With this, I drilled through the holes of the PCB where the two pins for the LED strip should be positioned and for the two for the power supply, from the top and the bottom.

Widen the Holes of the Pins from the Top with a Drill Bit

Widen the Holes of the Pins from the Bottom with a Drill Bit

Next, I soldered the screw terminals to the PCB. Here, I placed them on the bottom of the board as they would interfere with the pins for attaching the motor. Then, I soldered them from the top.

Pins of Screw Terminals Placed for Soldering

Position of Screw Terminals

Next, I soldered the capacitor that sits between the plus and minus of the power supply going to the motor driver. Here, I initially did not know how to position it. However, I just looked into its datasheet. And there, I found in the section "Polarity", the following sentence: "The polarity of an aluminum hybrid polymer capacitor is for SMT V-Chip types marked as follows: On the top of the component, the negative terminal is marked with a colored semicircle or bar". Hence, the pin below the red semicircle must be placed on top of the pad connecting to ground. Then, I was able to solder that component correctly.

Soldered Capacitor for Moter Power Supply

Lastly, I finished the soldering job by soldering the remaining male and female pin headers to the board. For the male pin headers I proceeded as shown above. The female pin however were a lot trickier. The female pin headers are used to mount the motor driver properly on the PCB but not permanently as these motor drivers blow up rather easily. To solder these pins, I placed both rows of female pins on the motor driver and connected all four pins on the ends to the PCB with some solder. Then, I removed the motor driver for space to position the solder iron between both rows. However, the pins were not that long and therefore I actually burned quite a bit of plastic of the female pins. Additionally, I made the mistake of firstly solder the pins for the phases of the motor and then the female pins. This took away a lot of space for the solder iron. Nevertheless, I managed it in the end even though it may not be pretty.

Finished PCB

Angled View on Finished PCB

Testing the Complete PCB

After having completed the soldering job, finally, I was able to test to full board for functionality. The first tests are always done with a multimeter to test for continuity where it should be present and where it should not be present. The details of these tests are described here. With these tests, I found that soldering was done correctly for all pins. So, apparently I am getting better at this!

Next, I supplied power to the board to see whether the power LED would turn on. For this, I connected the board to the programmer board as shown here. The programmer board was however not connected to my computer but to a socket via an USB cable and adapter. As I had done this, the LED power switched on. Furthermore, the built-in LED was blinking in a rhythm of one second per phase. This is due to the previous testing phase where only few components were soldered to the PCB. The microcontroller was still programmed to do this. With these tests done, I concluded that the board was functional.

For further tests with output and input devices, please refer to the respective weeks for output and input devices.

Design Files and Source Code for Download